import { createWebHistory, createRouter } from "vue-router";
import NProgress from "nprogress";
import "nprogress/nprogress.css";

import layout from "@/layout/homeIndex.vue";
const routes = [
	{
		path: "/",
		component: layout,
		redirect: "/encryption",
		meta: { title: "首页", showFooter: true, isAuth: false },
		children: [
			// 加密中心
			{
				path: "/encryption",
				component: () => import("@/views/encryption.vue"),
				meta: { title: "加密中心", showFooter: false },
			},
		],
	},
];

const router = createRouter({
	history: createWebHistory(),
	routes,
});
//前置路由守卫
router.beforeEach((to, from, next) => {
	NProgress.start();
	next();
});
// 后置路由守卫
router.afterEach(() => {
	NProgress.done();
});

export default router;
